from langchain_openai import ChatOpenAI
from browser_use import Agent, Controller
from browser_use.browser.browser import Browser, BrowserConfig
import asyncio
import os
from dotenv import load_dotenv
load_dotenv()
os.environ["ANONYMIZED_TELEMETRY"] = "false"
async def main():
    browser = Browser(
        config=BrowserConfig(
            headless=False,
            cdp_url='http://localhost:9222',
        )
    )
    controller = Controller()
    agent = Agent(
        task="Compare the price of gpt-4o and DeepSeek-V3",
        llm=ChatOpenAI(
            model="ep-20250210083830-wfwzm",
            api_key=os.getenv("OPENAI_API_KEY"),
            base_url=os.getenv('OPENAI_API_BASE')
            ),
        browser=browser,
        controller=controller,
    )
    result = await agent.run()
    print(result)
    await browser.close()
    input('Press Enter to close...')

asyncio.run(main())